package com.example.websocketdemo.API;

import com.alibaba.fastjson.JSON;
import com.example.websocketdemo.entity.video.Cameras;
import com.example.websocketdemo.entity.video.PreviewURLs;
import com.hikvision.artemis.sdk.ArtemisHttpUtil;
import com.hikvision.artemis.sdk.config.ArtemisConfig;

import java.util.HashMap;
import java.util.Map;


/**
 * Auto Create on 2021-10-15 02:26:00
 */
public class VideoOneApi {
    /**
     * STEP1：设置平台参数，根据实际情况,设置host appkey appsecret 三个参数.
     */
    static {
        ArtemisConfig.host = "192.168.100.4:443";
        ArtemisConfig.appKey = "24088673"; // 秘钥appkey
        ArtemisConfig.appSecret = "rNiT4CyBEjXiNfCdGb2G";
    }

    /**
     * STEP2：设置OpenAPI接口的上下文
     */
    private static final String ARTEMIS_PATH = "/artemis";

    //获取视频设备信息
    public String C(Cameras cameras) {
        String getDataApi = ARTEMIS_PATH + "/api/resource/v1/cameras";
        Map<String, String> path = new HashMap<String, String>(2) {
            {
                put("https://", getDataApi);
            }
        };
        String body = JSON.toJSONString(cameras);
        String result = ArtemisHttpUtil.doPostStringArtemis(path, body, null, null, "application/json");
        return result;
    }

    //获取视频设备信息
    public String P(PreviewURLs previewURLs) {
        String getDataApi = ARTEMIS_PATH + "/api/video/v2/cameras/previewURLs";
        Map<String, String> path = new HashMap<String, String>(2) {
            {
                put("https://", getDataApi);
            }
        };
        String body = JSON.toJSONString(previewURLs);
        String result = ArtemisHttpUtil.doPostStringArtemis(path, body, null, null, "application/json");
        return result;
    }


}
